package crmdna.member;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;

import crmdna.contactdetail.ContactDetailProp;
import crmdna.member.MemberCore.MemberProp;

@Entity
@Cache
public class MemberEntity {
	@Id
	long memberId;

	@Index
	String email;

	String firstName;
	String lastName;

	String homeAddress;
	String officeAddress;
	String homePhone;
	String officePhone;
	@Index
	String mobilePhone;

	@Index
	Set<Long> groupIds = new HashSet<>();

	@Index
	Set<String> qsTags;
	@Index
	Set<Long> programIds = new HashSet<>();

	String listUnverfiedProgramPropJson;

	Map<String, String> customFields;

	// dependents
	@Index
	String name;
	@Index
	String nameFirstChar;
	@Index
	Set<Long> programTypeIds = new HashSet<>();
	@Index
	Set<Long> practiceIds = new HashSet<>();
	@Index
	Set<String> phoneNumbers = new HashSet<>(); // not used - consider removing

	public MemberProp toProp() {
		MemberProp prop = new MemberProp();
		prop.memberId = memberId;
		prop.contact = new ContactDetailProp();
		prop.contact.email = email;
		prop.contact.firstName = firstName;
		prop.contact.lastName = lastName;
		prop.contact.homeAddress = homeAddress;
		prop.contact.officeAddress = officeAddress;
		prop.contact.homePhone = homePhone;
		prop.contact.officePhone = officePhone;
		prop.contact.mobilePhone = mobilePhone;

		prop.name = name;
		// prop.qsTags = qsTags;
		prop.groupIds = groupIds;

		prop.programIds = programIds;
		prop.programTypeIds = programTypeIds;
		prop.practiceIds = practiceIds;

		return prop;
	}
}
